package com.softhinker.ke24.unit2;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import com.softhinker.ke24.unit2.data.DataRetriever;
import com.softhinker.ke24.unit2.settings.Settings;
import com.softhinker.ke24.unit2.settings.SettingsPanel;
import com.softhinker.ke24.unit2.solution.BetterSolutionListener;
import com.softhinker.ke24.unit2.solution.IterationListener;
import com.softhinker.ke24.unit2.solution.MutationListener;
import com.softhinker.ke24.unit2.solution.SolutionPanel;

public class MainFace extends JFrame {

	private static final long serialVersionUID = -1400535829837982435L;

	public interface DataPanelCreator extends BetterSolutionListener, IterationListener, MutationListener{
		JComponent createDataPanel(DataRetriever dataRetriever);
		void reset();
	}
	
	public interface SettingsPanelCreator extends Settings{
		JComponent createSettingsPanel();
	}
	
	public interface SolutionPanelCreator{
		JComponent createSolutionPanel();
	}
	
//	private DataPanelCreator dataPanelCreator = new DataPanel();
	private SettingsPanelCreator settingsPanelCreator;
	private SolutionPanelCreator solutionPanelCreator;
	
	public MainFace() {
		// Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setSize(width / 2, height / 2);
        this.setLocationRelativeTo(null);
        this.setMinimumSize(new Dimension(650, 500));

        this.setTitle("KE-GA-CA : Load Distribution");
        init();
        this.pack();
        this.setVisible(true);
	}
	
	public void init()
	{
		JTabbedPane tabbedPane = new JTabbedPane();
		
//		tabbedPane.add("Data", dataPanelCreator.createDataPanel(new DefaultDataRetriever()));
		settingsPanelCreator = new SettingsPanel();
	    tabbedPane.add("Settings", settingsPanelCreator.createSettingsPanel());
	    solutionPanelCreator = new SolutionPanel(settingsPanelCreator);
		tabbedPane.add("Solution", solutionPanelCreator.createSolutionPanel());

		
		this.add(tabbedPane);
	}
	
}
